<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Call a Lua function</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="class.luasandboxfunction.html">« LuaSandboxFunction</a></li>
      <li style="float: right;"><a href="luasandboxfunction.construct.html">LuaSandboxFunction::__construct »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.luasandboxfunction.html">LuaSandboxFunction</a></li>
    <li>Call a Lua function</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="luasandboxfunction.call" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">LuaSandboxFunction::call</h1>
  <p class="verinfo">(PECL luasandbox &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">LuaSandboxFunction::call</span> &mdash; <span class="dc-title">Call a Lua function</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-luasandboxfunction.call-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>LuaSandboxFunction::call</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">...$args</code></span>): <span class="type"><span class="type">array</span>|<span class="type">bool</span></span></div>

  <p class="para rdfs-comment">
   Calls a Lua function.
  </p>
  <p class="para">
   Errors considered to be the fault of the PHP code will result in the
   function returning <code class="literal">false</code> and <strong><code>E_WARNING</code></strong>
   being raised, for example, a <span class="type">resource</span> type being used as an
   argument. Lua errors will result in a <span class="classname"><a href="class.luasandboxruntimeerror.html" class="classname">LuaSandboxRuntimeError</a></span>
   exception being thrown.
  </p>
  <p class="para">
   PHP and Lua types are converted as follows:
  </p>
  <p class="para">
   <ul class="itemizedlist">
    <li class="listitem">
     <p class="para">PHP <strong><code>null</code></strong> is Lua <code class="literal">nil</code>, and vice versa.</p>
    </li>
    <li class="listitem">
     <p class="para">
      PHP <span class="type">int</span>s and <span class="type">float</span>s are converted to Lua
      numbers. Infinity and <strong><code>NAN</code></strong> are supported.
     </p>
    </li>
    <li class="listitem">
     <p class="para">
      Lua numbers without a fractional part between approximately <code class="literal">-2**53</code>
      and <code class="literal">2**53</code> are converted to PHP <span class="type">int</span>s, with others
      being converted to PHP <span class="type">float</span>s.
     </p>
    </li>
    <li class="listitem">
     <p class="para">PHP <span class="type">bool</span>s are Lua booleans, and vice versa.</p>
    </li>
    <li class="listitem">
     <p class="para">PHP <span class="type">string</span>s are Lua strings, and vice versa.</p>
    </li>
    <li class="listitem">
     <p class="para">
      Lua functions are PHP <span class="classname"><a href="class.luasandboxfunction.html" class="classname">LuaSandboxFunction</a></span> objects, and vice versa.
      General PHP <span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span>s are not supported.
     </p>
    </li>
    <li class="listitem">
     <p class="para">
      PHP <span class="type">array</span>s are converted to Lua tables, and vice versa.
     </p>
     <p class="para">
      <ul class="itemizedlist">
       <li class="listitem">
        <p class="para">
         Note that Lua typically indexes arrays from 1, while PHP indexes
         arrays from 0. No adjustment is made for these differing
         conventions.
        </p>
       </li>
       <li class="listitem">
        <p class="para">Self-referential arrays are not supported in either direction.</p>
       </li>
       <li class="listitem">
        <p class="para">PHP references are dereferenced.</p>
       </li>
       <li class="listitem">
        <p class="para">
         Lua <code class="literal">__pairs</code> and <code class="literal">__ipairs</code> are processed.
         <code class="literal">__index</code> is ignored.
        </p>
       </li>
       <li class="listitem">
        <p class="para">
         When converting from PHP to Lua, integer keys between
         <code class="literal">-2**53</code> and <code class="literal">2**53</code> are represented
         as Lua numbers. All other keys are represented as Lua strings.
        </p>
       </li>
       <li class="listitem">
        <p class="para">
         When converting from Lua to PHP, keys other than strings and
         numbers will result in an error, as will collisions when converting
         numbers to strings or vice versa (since PHP considers things like
         <code class="literal">$a[0]</code> and <code class="literal">$a[&quot;0&quot;]</code> as being equivalent).
        </p>
       </li>
      </ul>
     </p>
    </li>
    <li class="listitem">
     <p class="para">
      All other types are unsupported and will raise an error/exception,
      including general PHP <span class="type">object</span>s and Lua userdata and thread types.
     </p>
    </li>
   </ul>
  </p>
  <p class="para">
   Lua functions inherently return a list of results. So on success, this
   method returns an <span class="type">array</span> containing all of the values returned by Lua,
   with <span class="type">int</span> keys starting from zero. Lua may return no results, in
   which case an empty array is returned.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-luasandboxfunction.call-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">args</code></dt>

    <dd>

     <p class="para">
      Arguments passed to the function.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-luasandboxfunction.call-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns an <span class="type">array</span> of values returned by the function, which may be empty,
   or <code class="literal">false</code> on error.
  </p>
 </div>


</div></div></div></body></html>